set cindent
set foldmethod=marker
" set foldmarker=\ st:\ ,\ ed:\ 
set foldmarker=#if,#endif
set foldlevel=3
" set rnu

let g:ag_prg="ag --column --cpp --cc"

if &makeprg == "make" && !filereadable("Makefile")
	set makeprg=Run\ %
endif

nnoremap <silent><C-W>] <Esc>:exe "ptjump " . expand("<cword>")<Esc>:let @/=expand("<cword>")<Esc>
set previewheight=20

" func! ShowBlockTitle()
" " " 	let s:line = searchpair('[^#]*\<if\>\|[^#]*\<else\>\|\<while\>\|\<for\>\|\<do\>\|\<switch\>', '', '}', 'bnW', 'getline(".") =~ "^[\\t ]*\\*"')
" 	let s:msg=""
" 	let s:line = searchpair("[\\t ]\\+{", '', "[\\t ]\\+}", 'bnW')
" 	let s:ret = getline(s:line)
" 	if s:ret !~ "^[\\t ]\\+.*"
" 		return ""
" 	endif
" 	let s:ret=system("echo -n \"".escape(getline(s:line), "\"")."\" | sed 's/}//;s/^[\\t ]*//;s/[\\t ]*{.*$//'")
" 
" 	if s:ret == ""
" 		if s:line > 1
" 			let s:line-=1
" 		endif
" 		let s:line = searchpair('[^#]*\<if\>\|[^#]*\<else\>\|\<while\>\|\<for\>\|\<do\>\|\<switch\>', '', '}', 'bnW')
" 		let s:msg=",1"
" 	endif
" 	if s:ret=~ "else"
" 		let s:line = searchpair('[^#]*\<if\>', '', '}', 'bnW')
" 		let s:msg=s:msg.",2"
" 	endif
" 	let s:ret=system("echo -n \"".escape(getline(s:line), "\"")."\" | sed 's/}//;s/^[\\t ]*//;s/[\\t ]*{.*$//'").",".s:ret
" 
" 	if s:ret == ""
" 		if s:line > 1
" 			let s:line-=1
" 		endif
" 		let s:msg=s:msg.",3"
" 		if s:ret=~ "else"
" 			let s:line = searchpair('[^#]*\<if\>\|[^#]*\<else\>\|\<while\>\|\<for\>\|\<do\>\|\<switch\>', '', '}', 'bnW')
" 			let s:msg=s:msg.",4"
" 		endif
" 		let s:msg=s:msg.",5"
" 		let s:ret=system("echo -n \"".escape(getline(s:line), "\"")."\" | sed 's/}//;s/^[\\t ]*//;s/[\\t ]*{.*$//'").",".s:ret
" 	endif
" " 	call cursor(s:lnum, s:col)
" " 	redraw!
" 	echo s:ret."-------".s:msg
" 	return s:ret
" endfun

" 		let s:line = searchpair('{', '', '}', 'bnW', 'getline(".") =~ "\\([\\t ]*\\/\\*\\|[\\t ]*\\/\\/\\)\|getline('.s:line.')"')

" func! ShowBlockTitle()
" 	let s:col=col(".")
" 	let s:lnum=line(".")
" 	let s:ret=""
" 	let s:line = searchpair('{', '', '}', 'bW', 'getline(".") =~ "\\([\\t ]*\\/\\*\\|[\\t ]*\\/\\/\\)"')
" 	let s:ret=system("echo -n \"".escape(getline(s:line-1), "\\\"")."\" | sed 's/}//;s/^[\\t ]*//;s/[\\t ]*{.*$//'")
" 	if s:ret == "else"
" 		call search('}', 'bW')
" 		let s:line = searchpair('{', '', '}', 'bnW', 'getline(".") =~ "\\([\\t ]*\\/\\*\\|[\\t ]*\\/\\/\\)"')
" 		let s:ret=system("echo -n \"".escape(getline(s:line-1), "\\\"")."\" | sed 's/}//;s/^[\\t ]*//;s/[\\t ]*{.*$//'").",".s:ret
" " 		echo "1----".s:ret."-----".s:line."-----"
" 	else
" 		let s:ret=system("echo -n \"".escape(getline(prevnonblank(s:line-1)), "\\\"")."\" | sed 's/}//;s/^[\\t ]*//;s/[\\t ]*{.*$//'")
" " 		echo "2----".s:ret."-----".s:line."-----"
" 	endif
" " 	call cursor(s:lnum, s:col)
" 	call search("\\%" . s:lnum . "l" . "\\%" . s:col . "c")
" 	redraw!
" 	return s:ret
" endfunc
" " set statusline=%n:%t:%{ShowFuncName()}:%{ShowBlockTitle()}\ %m%r%=T:%L,C:%c%V\ (%P)
" set statusline=%#blue#%n%#green#:%{ShowFuncName()}%#red#:%{ShowBlockTitle()}\ %m%r%#grey#%=%#magenta#C:%c%V\ (%P)

" set makeprg=Run\ %

"inoremap { {}<LEFT>
"inoremap {<TAB> {<CR>}<UP><CR>
"inoremap " ""<LEFT>
"inoremap ( ()<LEFT>
"inoremap [ []<LEFT>
"imap { {<TAB>
"imap " "<TAB>
"imap ' '<TAB>
"imap ( (<TAB>
"imap [ [<TAB>
"inoremap <A-h> <LEFT>
"inoremap <A-j> <DOWN>
"inoremap <A-k> <UP>
"inoremap <A-l> <RIGHT>
"inoremap <A-h> <C-o>h
"inoremap <A-j> <C-o>j
"inoremap <A-k> <C-o>k
"inoremap <A-l> <C-o>l
"inoremap <A-b> <C-o>b
"inoremap <A-w> <C-o>w
inoremap <A-S-b> <C-o>B
"inoremap <A-S-w> <C-o>W

"func! s:mynotab()
	"iunmap <Tab>
"endfunc
"func! s:mytabmap1()
	"inoremap <silent><Tab> <ESC>:exe "normal f)"<CR>:call <SID>mynotab()<CR>a
"endfunc
"func! s:mytabmap2()
	"inoremap <silent><Tab> <ESC>:exe "normal f]"<CR>:call <SID>mynotab()<CR>a
"endfunc
"func! s:mytabmap3()
	"inoremap <silent><Tab> <ESC>:exe "normal f}"<CR>:call <SID>mynotab()<CR>a
"endfunc
""func! s:mytabmap1(char)
	""echo a:char
	""inoremap <silent><Tab> <ESC>:exe "normal f".a:char<CR>:call <SID>mynotab()<CR>a
""endfunc
""inoremap <silent>( ()<ESC>:call <SID>mytabmap1(')')<CR>i
"inoremap <silent>( ()<ESC>:call <SID>mytabmap1()<CR>i
"inoremap <silent>[ []<ESC>:call <SID>mytabmap2()<CR>i
"inoremap <silent>{ {<ESC>:call <SID>mytabmap3()<CR>o<CR>}<ESC>kA
" com! -range D <line1>,<line2>call Debug("ZHIMINCX_DEBUG","(\"T#%s:%d?@0\\n\", FILENAME, __LINE__);")
